package com.hanqian.kepler.core.service.core.impl;

import com.hanqian.kepler.common.base.dao.BaseDao;
import com.hanqian.kepler.common.base.service.BaseServiceImpl;
import com.hanqian.kepler.common.enums.BaseEnumManager;
import com.hanqian.kepler.common.jpa.specification.Rule;
import com.hanqian.kepler.common.jpa.specification.SpecificationFactory;
import com.hanqian.kepler.core.dao.primary.core.TargetEvaluateDetailDao;
import com.hanqian.kepler.core.entity.primary.core.TargetEvaluate;
import com.hanqian.kepler.core.entity.primary.core.TargetEvaluateDetail;
import com.hanqian.kepler.core.service.core.TargetEvaluateDetailService;
import com.hanqian.kepler.flow.enums.FlowEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * new file
 * ======================================
 *
 * @author dzw
 * @date 2021/1/26 16:14
 * =======================================
 */
@Service
public class TargetEvaluateDetailServiceImpl extends BaseServiceImpl<TargetEvaluateDetail, String> implements TargetEvaluateDetailService {

    @Autowired
    private TargetEvaluateDetailDao targetEvaluateDetailDao;

    @Override
    public BaseDao<TargetEvaluateDetail, String> getBaseDao() {
        return targetEvaluateDetailDao;
    }

    @Override
    public List<TargetEvaluateDetail> findDetailList(TargetEvaluate targetEvaluate) {
        List<TargetEvaluateDetail> targetEvaluateDetailList = new ArrayList<>();
        if(targetEvaluate == null) return targetEvaluateDetailList;
        List<Rule> rules = new ArrayList<>();
        rules.add(Rule.eq("state", BaseEnumManager.StateEnum.Enable));
        rules.add(Rule.eq("targetEvaluate", targetEvaluate));
        return findAll(SpecificationFactory.where(rules));
    }
}
